var BaseAnimate = ccs.Armature.extend({
    _animations : null,
	ctor:function (name, parentBone) {
        //////////////////////////////
		this._super(name, parentBone);
        //////////////////////////////
        return true;
    },
    onEnter:function () {
    	this._super();
    	this.animations();        
    },
    animations : function(){
    	if ( null==this._animations ){
    		this._animations=this.getAnimation();
    	}
    	return this._animations
    },
    goBack : function(scale){
        if(null==scale){
            this.setScale(-1);
        }else{
            this.setScale(-scale);
        }
    },
    goAhead : function(scale){
        if(null==scale){
            this.setScale(1);
        }else{
        	this.setScale(scale);
        }
    },
    playAction : function(id){
    	if(null==id){
    		this.animations().playWithIndex(0);
        }else{
            /*var action=id;
            if ( action > this.animations().getMovementCount() )
                action-=this.animations().getMovementCount();//*/
            this.animations().playWithIndex(id);
        }
    },
    addPlaySpeed : function(add){
        if(null==add){
        	this.animations().setSpeedScale(this.animations().getSpeedScale());
        }else{
        	this.animations().setSpeedScale(this.animations().getSpeedScale()+add);
        }
    },
    subPlaySpeed : function(sub){
    	if(null==sub){
    		this.animations().setSpeedScale(this.animations().getSpeedScale());
        }else{
        	this.animations().setSpeedScale(this.animations().getSpeedScale()-sub);
        }
    },
    setPlaySpeed : function(speed){
        if(null==speed){
        	this.animations().setSpeedScale(this.animations().getSpeedScale());
        }else{
        	this.animations().setSpeedScale(speed);
        }
    },
    addFrameEventCallback : function(callFunc,target){
		if(null==callFunc){
			this.animations().setFrameEventCallFunc(this.frameEventCallback,this);
		}else{
			this.animations().setFrameEventCallFunc(callFunc,target);
		}
	},
    addMovementEventCallback : function(callFunc,target){
        if(null==callFunc){
            this.animations().setMovementEventCallFunc(this.movementEventCallback,this);
        }else{
            this.animations().setMovementEventCallFunc(callFunc,target);
        }
    },
    frameEventCallback: function (bone, frameEventName, originFrameIndex, currentFrameIndex) {
        cc.log("***BaseAnimate frameEvent");
    },
    movementEventCallback : function( target, type, actionName ){
        switch(type){
            case ccs.MovementEventType.start:{
                cc.log("***BaseAnimate movementEvent start");
                break;
            }
            case ccs.MovementEventType.complete:{
                cc.log("***BaseAnimate movementEvent end");
                break;
            }
            case ccs.MovementEventType.loopComplete:{
                cc.log("***BaseAnimate movementEvent loop end");
                break;
            }
        }
    }
   
});
BaseAnimate.create = function(name, parentBone){
	var anim = new BaseAnimate(name, parentBone);
	if (anim && anim.init(name)) {
		return anim;
	}
	return null;
}

ArmatureResourceLoad = function(filename)
{
    cc.log("***load armature name: "+filename);
	// load resource first
	ccs.armatureDataManager.addArmatureFileInfo(filename+".ExportJson");
}
ArmatureResourceRemove = function(filename)
{
    cc.log("***remove armature name: "+filename);
	// remove resource first
	ccs.armatureDataManager.removeArmatureFileInfo(filename+".ExportJson");
}
